package com.wms.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wms.bean.PageBean;
import com.wms.entity.Supplier;
import com.wms.mapper.SupplierMapper;
import com.wms.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierServiceImpl implements SupplierService {

    @Autowired
    SupplierMapper supplierMapper;

    @Override
    public List<Supplier> getAll() {
        return supplierMapper.selectAll();
    }

    @Override
    public List<Supplier> queryByCondition(Supplier supplier) {
        return supplierMapper.selectByCondition(supplier);
    }

    @Override
    public List<Supplier> queryById(int id) {
        return supplierMapper.selectById(id);
    }

    @Override
    public int saveSupplier(Supplier supplier) {
        return supplierMapper.addSupplier(supplier);
    }

    @Override
    public PageBean queryByPage(int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        List list = supplierMapper.selectByPage();
        PageInfo info = new PageInfo(list);
        return new PageBean(page, pageSize, info.getTotal(), list);
    }
}
